package WaiBao;

import java.util.Arrays;

public class GuoXiaoJing {
    public static void main(String[] args) {
        String[] name = {"故事(班长)", "李存勖(副班长)", "小李(学习委员)", "李大虎(体育委员)", "郭敬明", "成龙", "张学友", "称之为", "吴君如", "杨迪", "唐艺昕", "王传君",
                "陈赫", "程邹", "李佳航", "张委", "张伟", "韩轩", "韩玄", "邢道荣", "吕布", "董卓", "孟获", "曹操", "司马懿", "司马思", "司马昭", "荀彧",
                "张杰", "郭小静(学生)"};//考生本人:郭小静(学生)
        int[] age = {18, 19, 21, 18, 19, 20, 21, 21, 19, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 20};//考生年龄20


        double[] m1 = {64, 84, 85, 90, 80, 69, 78, 59, 60, 70, 90, 87, 85, 79, 65, 68, 69, 90, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 84, 95};
        double[] m2 = {64, 84, 77, 69, 68, 97, 84, 99, 90, 94, 90, 67, 86, 77, 65, 65, 86, 79, 64, 78, 82, 71, 85, 85, 75, 89, 74, 78, 87, 93};
        double[] m3 = {38, 89, 89, 95, 99, 99, 69, 89, 80, 60, 93, 87, 85, 85, 65, 90, 89, 79, 96, 63, 92, 81, 90, 85, 76, 88, 73, 70, 78, 94};


        double bu1;//代表每个学生的总分
        double bu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            bu1 = m1[i] + m2[i] +m3[i];
//            bu2 = (bu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + bu1);
//            System.out.println(name[i] + "的平均分为:" +bu2);
//        }

        double nide1 = 0, nide2 = 0;
        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            nide1 = m1[i] + m2[i] + m3[i];
//            nide2 = (nide1 * 1.0) / 3;
//            Array[i] = nide2;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double temp = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }



        double heep1 = 0, heep2 = 0, heep3 = 0;//计算每门课的平均分
        double f1 = 0, f2 = 0, f3 = 0;//计算每门课标准差
        double lang1 = 0, lang2 = 0, lang3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < m1.length; i++) {
            sum2+=m1[i];
        }
        heep1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+heep1);
        double Sum = 0;
        for (int i = 0; i < m2.length; i++) {
            Sum+=m2[i];
        }
        heep2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+heep2);
        double sum = 0;
        for (int i = 0; i <m3.length; i++) {
            sum+=m3[i];
        }
        heep3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+heep3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < m1.length; i++) {
            c1+= (m1[i] - heep1)*(m1[i] - heep1);
        }
        f1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+f1);

        for (int i = 0; i < m2.length; i++) {
            c2+= (m2[i] - heep2)*(m2[i] - heep2);
        }
        f2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+f2);

        for (int i = 0; i < m3.length; i++) {
            c3+= (m3[i] - heep3)*(m3[i] - heep3);
        }
        f3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+f3);

        Arrays.sort(m1);
        Arrays.sort(m2);
        Arrays.sort(m3);
        lang1 =( m1[15]+m1[14])*1.0/2;
        lang2 =( m2[15]+m2[14])*1.0/2;
        lang3 =( m3[15]+m3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+lang1);
        System.out.println("线性代数的中位数为:"+lang2);
        System.out.println("有机化学学的中位数为:"+lang3);






    }
}
